package com.socialcoco.config;

import com.socialcoco.bean.user;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

/**
 * 自定义参数解析器
 */
@Component
public class MyArgumentResolver implements HandlerMethodArgumentResolver {
    //这个方法判断参数类型是否匹配
    @Override
    public boolean supportsParameter(MethodParameter parameter) {
        return parameter.getParameterType().isAssignableFrom(user.class);
    }
    //返回匹配参数的处理结果
    @Override
    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
                                  NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

        /**
         * 这里写通过参数的时候要判断的东西
         */
        return null;
    }
}
